package com.my.commonlibrary.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.duowan.mobile.netroid.Listener;
import com.duowan.mobile.netroid.NetroidError;
import com.my.commonlibrary.R;
import com.my.commonlibrary.base.BaseFragment;
import com.my.commonlibrary.net.netroid.Netroid;
import com.my.commonlibrary.net.netroid.Network;
import com.my.commonlibrary.net.netroid.Urls;
import com.my.commonlibrary.net.retrofit.ApiManager;
import com.my.commonlibrary.utils.ToastUtil;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Author : Cooper
 * Time : 2016/11/4  16:03
 * Description :
 */

public class H_NetroidFragment extends BaseFragment {

    @Bind(R.id.load_bt)
    Button loadBt;
    @Bind(R.id.respone_content_tv)
    TextView responeContentTv;

    @Override
    protected int getFragmentLayoutRes() {
        return R.layout.frag_home_retrofit_layout;
    }

    @Override
    protected void initFragmentData() {

    }
    @OnClick(R.id.load_bt)
    public void onClick() {
        Network.getInstance(getActivity()).get(Urls.getUrl(Urls.RUL_USER_INFO), new Listener() {
            @Override
            public void onSuccess(Object response) {
                responeContentTv.setText(response.toString());
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                ToastUtil.showToast("错误了~~~");
            }
        });
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
